import { store } from '@/store/setup'
import { defineStore } from 'pinia'
// import { bwUtilsCookie } from '@/utils'

import type { BwCurtomComInfoStoreModel } from './models'
import type {
  SysAppInfoOutupu,
  SysCustomComInfoOutupu,
  SysCustomComRenderOutupu,
} from './utils/axios/model'

const useComInfoStore = defineStore({
  id: 'BwCurtomComInfoStore',
  state: (): BwCurtomComInfoStoreModel => ({
    curAppInfo: null,
    curComInfo: null,
    curComRenderInfo: null,
  }),
  getters: {},
  actions: {
    /** 设置应用信息 */
    setAppInfo(info: Nullable<SysAppInfoOutupu>) {
      this.curAppInfo = info
    },

    /** 设置应用信息 */
    setComInfo(info: Nullable<SysCustomComInfoOutupu>) {
      this.curComInfo = info
    },

    /** 设置应用信息 */
    setComRenderInfo(info: Nullable<SysCustomComRenderOutupu>) {
      this.curComRenderInfo = info
    },
  },
})

// Need to be used outside the setup
export function useComInfoStoreWithOut() {
  return useComInfoStore(store)
}
